package com.asiainfo.kbisheet.control
{
	import com.asiainfo.kbisheet.common.Util;
	import com.asiainfo.kbisheet.model.ListModel;
	
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;

	public class ListControl
	{
		internal var _service:RemoteObject;       		
		internal var listModel:ListModel = ListModel.getInstance();
		
		public function ListControl()
		{
			_service = new RemoteObject();            	
			_service.destination = "flexService";
			_service.endpoint = "messagebroker/amf";
			_service.showBusyCursor = true;
			_service.addEventListener(FaultEvent.FAULT, Util.faultHandler);
			_service.getAllKbsSheetVOList.addEventListener(ResultEvent.RESULT, getAllKbsSheetVOListResult);
			_service.scanXMLDir.addEventListener(ResultEvent.RESULT, scanXMLDirResult);
		}
		
		public function getAllKbsSheetVOList():void{
			_service.getAllKbsSheetVOList();
		}
		
		/*更新文件列表*/
		public function refreshFile():void{
			_service.scanXMLDir();
		}

		private function getAllKbsSheetVOListResult(event:ResultEvent):void{
			listModel.kbsSheetVOAC = _service.getAllKbsSheetVOList.lastResult;
		}
		
		/*更新文件列表的结果*/
		private function scanXMLDirResult(event:ResultEvent):void{
			getAllKbsSheetVOList();
		}
	}
}